Page({
  data: {},
  sendSubscribeMessage(e) {
    console.log(e, '=====');
    let that = this;
    wx.login({
      success: (res) => {
        console.log(res, "res");
        wx.request({
          url: 'http://127.0.0.1:8080/v1/ma/messages/subscribe',
          method: 'POST',
          data: {
            wxLoginJsCode: res.code,
            template_id: '2FaPnEbeUFzT339nWaslzyEoCDgyKijq1dNvJj8aUms',
            page: 'pages/index/index',
            data: {
              // 活动名称
              thing5: {
                value: '抽奖'
              },
              // 领取方式
              thing6: {
                value: '关注公众号联系客服小姐姐领取'
              },
              // 活动商品
              thing2: {
                value: 'iPhone 14'
              }
            }
          },
          complete: (res) => {
            that.setData({
              msgSendResult: JSON.stringify(res.data.data, null, 2)
            })
          }
        })
      }
    })
  },
  requestSubscribeMessage(e) {
    wx.requestSubscribeMessage({
      tmplIds: [
        //templateIds
        'xyVBB18cqk_K9a3FSf-TfKKY5m3oAboxQ-K8mhuSmAA',
        '7NZIGHJXkd2pGeL9DW2IHb_K8Oz-q84bwLA8TlP9Ndw',
        '6xJoVvHKfFjlSYIDFlzWlxSc0fcNiklgyMseikVCvuM'
      ],
      success: (res) => {
        console.log(res, "success")
      },
      fail: (res) => {
        console.log(res, "fail")
      },
      complete: (res) => {
        console.log(res, "complete")
      }

    })
  },
  getCurrentUserSettings(e) {
    wx.getSetting({
      withSubscriptions: true,
      success(res) {
        console.log(res.authSetting, "res.authSetting")
        // res.authSetting = {
        //   "scope.userInfo": true,
        //   "scope.userLocation": true
        // }
        console.log(res.subscriptionsSetting, "res.subscriptionsSetting")
        // res.subscriptionsSetting = {
        //   mainSwitch: true, // 订阅消息总开关
        //   itemSettings: {   // 每一项开关
        //     SYS_MSG_TYPE_INTERACTIVE: 'accept', // 小游戏系统订阅消息
        //     SYS_MSG_TYPE_RANK: 'accept'
        //     zun-LzcQyW-edafCVvzPkK4de2Rllr1fFpw2A_x0oXE: 'reject', // 普通一次性订阅消息
        //     ke_OZC_66gZxALLcsuI7ilCJSP2OJ2vWo2ooUPpkWrw: 'ban',
        //   }
        // }
      }
    })

    wx.openSetting({
      success(res) {
        console.log(res.authSetting, "res.authSetting")
        // res.authSetting = {
        //   "scope.userInfo": true,
        //   "scope.userLocation": true
        // }
      }
    })
  }


})